import socket

def main():
    #  创建TCP套接字
    tcp_client  = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    
    #  输入IP和端口
    server_ip = input('请输入IP:')
    server_port = int(input('请输入PORT:'))
    server_addr=(server_ip,server_port)
    
    #  连接服务器  也能直接输入IP和端口连接
    tcp_client.connect(server_addr)
    
    #  发送内容
    while True:
        send_data = input('请输入发送内容:')
        tcp_client.send(send_data.encode('utf-8'))
    
    #   关闭
    tcp_client.close()
if __name__  == '__main__':
    main()
